<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
	<div class="row">

		<div class="col-sm-12 search-collapse">
			<form id="formId">
				<input id="divice_id" name="diviceId" type="hidden">
				<!--<input id="bigName" name="bigName" type="hidden">-->
				<!--<input id="midName" name="bigName" type="hidden">-->
				<div class="select-list">
					<ul>

						<li>
							名称：<input type="text" name="name"/>
						</li>

						<li>
							物质编码：<input type="text" name="code"/>
						</li>

						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
	</div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('assets:pDevice:edit')}]];
    var removeFlag = [[${@permission.hasPermi('assets:pDevice:remove')}]];
    var prefix = ctx + "assets/bDivice";

    var pointId = $("#pointId").val();
    console.log("设备页面pointID=="+pointId)

    $(function() {
        var options = {
            url: prefix + "/list?pointId="+pointId,
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "配电设备库",
            showSearch:false,		//是否显示检索信息
            showRefresh:false,		//是否显示刷新按钮
            showToggle:false,		//是否显示详细视图和列表视图的切换按钮
            showColumns:false,		//是否显示隐藏某列下拉框
            sortable:false,		 	//是否启用排序
            columns: [{
                checkbox: true
            },
                {
                    field : 'id',
                    title : '',
                    visible: false
                },
                {
                    field : 'bDiveceId',
                    title : '所属设备ID',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'pointId',
                    title : '点位ID',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'lineId',
                    title : '线路ID',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'byqId',
                    title : '变压器ID',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'bigType',
                    title : '大类',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'midType',
                    title : '中类',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'lable',
                    title : '标签',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'name',
                    title : '名称',
                    sortable: true
                },
                {
                    field : 'modle',
                    title : '规格型号',
                    sortable: true
                },
                {
                    field : 'code',
                    title : '物质编码',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'unit',
                    title : '单位',
                    sortable: true
                },{
                    field : 'price',
                    title : '价格',
                    sortable: true
                },
                {
                    field : 'barCode',
                    title : '条形码',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'techParameter',
                    title : '技术参数',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'addDate',
                    title : '发布状态',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'addUser',
                    title : '新增人',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'updateUser',
                    title : '更新人',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'updateDate',
                    title : '更新时间',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'datastate',
                    title : '数据状态',
                    sortable: true,
                    visible: false
                },
                {
                    field : 'taskId',
                    title : '任务ID',
                    sortable: true,
                    visible: false
                }
			]
        };
        $.table.init(options);

        //	对所选设备添加到数组进行传值到后台添加
        $('#bootstrap-table').on('uncheck.bs.table check.bs.table check-all.bs.table uncheck-all.bs.table',function(e,rows){
            var datas = $.isArray(rows) ? rows : [rows];        // 点击时获取选中的行或取消选中的行
            examine(e.type,datas);                              // 保存到全局 Array() 里
        });

        var overAllIds = new Array();  //全局数组

        function examine(type,datas){

            console.log("type 0705 =="+JSON.stringify(type))
            console.log("datas 0705 =="+JSON.stringify(datas))

            if(type.indexOf('uncheck')==-1){
                $.each(datas,function(i,v){
                    // 添加时，判断一行或多行的 id 是否已经在数组里 不存则添加　
                    overAllIds.indexOf(v.id) == -1 ? overAllIds.push(v.id) : -1;
                });
            }else{
                $.each(datas,function(i,v){
                    overAllIds.splice(overAllIds.indexOf(v.id),1);    //删除取消选中行
                });
            }
            console.log("overAllIds=="+overAllIds);
            $("#divice_id").val(overAllIds);
//            $("#divice_id").val(overAllIds);
//            $("#divice_id").val(overAllIds);
        }


    });
</script>
</body>
</html>